Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    currentTab: 0,
    swiperHeight: 200,
    yx1list:[
      {
        id:0,
        title:"哥伦比亚大学",
        En_title:"Columbia University in the City of New York",
        img_url:"https://img.js.design/assets/img/6282160b192152a4d641b259.png",
        goto:"",
      },
      {
        id:1,
        title:"纽约电影学院",
        En_title:"New York Film Academy",
        img_url:"https://img.js.design/assets/img/62821a4e19215273b54295b0.png",
        goto:"",
      }
    ],
    yx2list:[
      {
        id:0,
        title:"多伦多大学",
        En_title:"University of Toronto",
        img_url:"https://img-blog.csdnimg.cn/e9fc8fd311ad4934800e6eaca803925e.png",
        goto:"",
      }
    ],
    yx3list:[
      {
        id:0,
        title:"新加坡国立大学",
        En_title:"National University of Singapore",
        img_url:"https://img-blog.csdnimg.cn/89eaac17ee244e9dae24fccfda128355.png",
        goto:"",
      },
    ],
    
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setSwiperHeight()
  },
 
  //以下为tab事件
  setSwiperHeight: function () {
    let that = this
 
    // 创建节点选择器
    let query = wx.createSelectorQuery();
    query.select('.swiper-view-' + that.data.currentTab).boundingClientRect((rect) => {
      let rectHeight = rect.height; // 获取高度
      that.setData({
        swiperHeight: rectHeight > 200 ? rectHeight : 200
      })
 
      console.log(JSON.stringify(rect))
    })
    query.exec()
  },
  //tab切换函数，让swiper当前滑块的current的index与tab头部index一一对应
  switchNav: function (e) {
    var index = e.target.dataset.current;
    if (this.data.currentTab == index) {
      return false;
    } else {
      this.setData({
        currentTab: index
      });
    }
 
    this.setSwiperHeight()
  },
  //滑动swiper切换，让swiper当前滑块的current的index与tab头部index一一对应
  tabChange(e) {
    this.setData({
      currentTab: e.detail.current
    })
 
    this.setSwiperHeight()
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
 
  }
})